package com.nf.health.app.models;

import android.text.TextUtils;

import com.nf.health.app.utils.DateUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by Jason on 2016/5/23.
 * {
 "yValue": [
 "42.0",
 "41.0",
 "39.0",
 "39.0",
 "36.6",
 "36.6",
 "36.6",
 "36.6",
 "37.0",
 "37.0"
 ],
 "min": "30",
 "unit": "℃",
 "max": "42.0",
 "normal_max": "42",
 "name": "温度",
 "xValue": [
 "1463721412000",
 "1463721414000",
 "1463721418000",
 "1463721418000",
 "1463971837000",
 "1463971837000",
 "1463980496000",
 "1463980496000",
 "1463980501000",
 "1463980501000"
 ],
 "isSpecial": "0",
 "normal_min": "30",
 "y_array": [
 "0.0",
 "20.0",
 "40.0",
 "60.0",
 "80.0"
 ],
 "column_key": "temp"
 }
 */
public class TempertuerHistoryModel implements Serializable{
    private String posttime;
    private String temp_status;
    private String id;
    private String temp;
    private String source;
    private String userid;
    private boolean isOpen = false;//listView的item的展开状态
   /* {
        "id": 1190,
            "temp_status": "正常",
            "source": "APP",
            "posttime": "2016-05-23 13:15:01",
            "userid": "2015120713580271544620",
            "temp": 37
    },*/

    public String getPosttime() {
        return posttime;
    }

    public void setPosttime(String posttime) {
        this.posttime = posttime;
    }

    public String getTemp_status() {
        return temp_status;
    }

    public void setTemp_status(String temp_status) {
        this.temp_status = temp_status;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTemp() {
        return temp;
    }

    public void setTemp(String temp) {
        this.temp = temp;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getUserid() {
        return userid;
    }

    public void setIsOpen(boolean isOpen) {
        this.isOpen = isOpen;
    }
    public boolean getIsOpen() {
        return isOpen;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public TempertuerHistoryModel parseTempertuerHistoryModel(String responseDate,String responseTem){
        TempertuerHistoryModel model = new TempertuerHistoryModel();
        if(!TextUtils.isEmpty(responseDate)){
            Date t1 = DateUtil.string2Date(responseDate, "yyyy年-MM月-dd日 HH时:MM分");
            model.setPosttime(t1.toString());
        }
        return model;
    }
    public TempertuerHistoryModel parseTempertuerHistoryModel(String responseDate){
        TempertuerHistoryModel model = new TempertuerHistoryModel();
        try {
            JSONObject obj = new JSONObject(responseDate);
            model.setId(obj.optString("id"));
            model.setPosttime(obj.optString("posttime"));
            model.setTemp(obj.optString("temp"));
            model.setTemp_status(obj.optString("temp_status"));
            model.setUserid(obj.optString("userid"));
            model.setSource(obj.optString("source"));
            model.setIsOpen(false);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return model;
    }
}
